<template>
  <div class="dashboard-container">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card>
          <h3>{{ $t('myLang.workclander') }}</h3>
          <mywrok></mywrok>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card>
          <h3>{{ $t('myLang.guess') }}</h3>
          <el-button @click="changeLang">点我切换语言</el-button>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  name: 'Dashboard',
  components: {
    mywrok: () => import('@/components/work-calendar')
  },
  methods: {
    changeLang () {
      // 切换语言
      // 得到当前的语言
      console.log(this.$i18n.locale)
      // 修改语言
      if (this.$i18n.locale === 'zh') {
        this.$i18n.locale = 'en'
      } else {
        this.$i18n.locale = 'zh'
      }
      // 重新保存语言
      Cookie.set('lang', this.$i18n.locale)
      // 将语言类型保存到 cookie 中
      // 刷新页面
      this.$router.go(0)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-container {
  margin: 20px;
  h3 {
    border-bottom: 1px solid #ccc;
    padding-bottom: 20px;
  }
}
</style>
